import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'

dayjs.extend(utc)
dayjs.extend(timezone)

export const formatDate = (dateString, showTime = false) => {
  const date = dayjs(dateString)
  const localDate = date.tz(dayjs.tz.guess())
  
  return localDate.format(showTime 
    ? 'YYYY-MM-DD HH:mm:ss'
    : 'YYYY-MM-DD'
  )
}